package com.ruoyi.campus.domain;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * TreeSelect树结构实体类
 * @author zht
 * @date 2021/12/10 13:15
 */
public class TreeSelects implements Serializable
{
    private static final long serialVersionUID = 1L;
    /** 节点ID */
    private Long id;

    /** 节点名称 */
    private String label;

    /** 节点图标 */
    private String icon;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelects> children;

    public TreeSelects()
    {

    }

    public TreeSelects(MyCommodityType type){
        this.id = type.getTypeId();
        this.label = type.getTypeName();
        this.icon = type.getIcon();
        this.children = type.getChildren().stream().map(TreeSelects::new).collect(Collectors.toList());
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public List<TreeSelects> getChildren() {
        return children;
    }

    public void setChildren(List<TreeSelects> children) {
        this.children = children;
    }
}
